home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13153 < prev    next >
Encoding:
Text File  |  1996-08-05  |  995 b   |  39 lines

  1. Path: CS.Arizona.EDU!not-for-mail
  2. From: kdb@CS.Arizona.EDU (Koen De Bosschere)
  3. Newsgroups: comp.lang.c++
  4. Subject: mutual data structures
  5. Date: 23 Mar 1996 13:28:49 -0700
  6. Organization: University of Arizona CS Department, Tucson AZ
  7. Message-ID: <4j1mu1$fas@baskerville.CS.Arizona.EDU>
  8. NNTP-Posting-Host: baskerville.cs.arizona.edu
  9.  
  10. I am trying to create a data structure consisting of 
  11. two linked lists, with nodes pointing at each other
  12. between the two lists. 
  13.  
  14. The problem is that in order to create typed pointers, I
  15. need the definition of the class, and no matter how I reorder
  16. the class definitions, there will always be an undefined
  17. class at some point.
  18.  
  19. class node1 {
  20. ....
  21. node2 *pointer;   // node2 undefined at this point
  22. ....
  23. };
  24.  
  25. class node2 {
  26. ....
  27. node1 *pointer;
  28. ....
  29. };
  30.  
  31. I was wondering whether there is an elegant solution 
  32. for this kind of problem. This kind of data structure
  33. cannot be so unusual, so other people must have faced
  34. this problem before.
  35.  
  36. Thanks
  37.  
  38. -- Koen De Bosschere
  39.